package com.jinxin.platform.cdinfogo.controller;

import com.jinxin.platform.base.common.pojo.JsonResult;
import com.jinxin.platform.cdinfogo.pojo.domain.CdinfogoDevice;
import com.jinxin.platform.cdinfogo.pojo.form.DeviceForm;
import com.jinxin.platform.cdinfogo.pojo.vo.DictEntity;
import com.jinxin.platform.cdinfogo.rpc.CdInfoGoRpcService;
import com.jinxin.platform.cdinfogo.service.CdinfogoDeviceService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * (CdinfogoDevice)表控制层
 *
 * @author zhangpeng
 * @since 2021-06-28 17:23:37
 */
@RestController
@RequestMapping("cdinfogoDevice")
public class CdinfogoDeviceController {
    /**
     * 服务对象
     */
    @Resource
    private CdinfogoDeviceService cdinfogoDeviceService;
    @Resource
    private CdInfoGoRpcService cdInfoGoRpcService;

    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @GetMapping("selectOne")
    public JsonResult selectOne(String id) {
        return this.cdinfogoDeviceService.queryById(id);
    }

    @PostMapping("pageList")
    public JsonResult pageList(DeviceForm deviceForm){
        return cdinfogoDeviceService.pageList(deviceForm);
    }

    @GetMapping("updateDevice")
    public JsonResult updateDevice(){
        return cdinfogoDeviceService.updateDevice();
    }

    @GetMapping("getKQ")
    public JsonResult getKq(){
        Map<String,String> map = new HashMap<>();
        map.put("dictKey","cdfaceacsTeam");
        List<DictEntity> dict = cdInfoGoRpcService.getDict(map);
        return JsonResult.ok(dict);
    }

    @GetMapping("getDeviceContent")
    public JsonResult getDeviceContent(String deviceId){
        return cdinfogoDeviceService.queryCentByDeviceId(deviceId);
    }

    @PostMapping("controllerDevice")
    public JsonResult controllerDevice(String ids){
        return cdinfogoDeviceService.controllerDevice(ids);
    }

    @PostMapping("deleteById")
    public JsonResult deleteById(String id){
        return cdinfogoDeviceService.deleteById(id);
    }
}